COMPILER = nvcci.sh

INTEL_COMPILER = icpc 

BIN_DIR = bin

INCLUDE = ./include

COMMON_SRC = common/dept150_common.cpp
COMMON_INCLUDE= ./common


CHOL_CUDA_SRC = cholesky_cuda/*.cpp

CHOL_CUDA_MGPU_SRC = cholesky_cuda_multi_gpu/*.cpp

TEST_CHOL_GPU_FACTOR_SRC = cholesky_cuda_multi_gpu/dept150_cholesky_mgpu.cpp test/chol_cuda_multi_gpu/gpu_factor.cpp
TEST_CHOL_SYS_SOLVE_SRC = cholesky_cuda_multi_gpu/dept150_cholesky_mgpu.cpp test/chol_cuda_multi_gpu/chol_system_solve.cpp

TEST_GAUS_GPU_FACTOR_SRC = gaus_cuda_multi_gpu/dept150_gaus_mgpu.cpp test/gaus_cuda_multi_gpu/gaus_gpu_factor.cpp
TEST_GAUS_SYS_SOLVE_SRC = gaus_cuda_multi_gpu/dept150_gaus_mgpu.cpp test/gaus_cuda_multi_gpu/gaus_system_solve.cpp

TEST_CHOL_ONE_GPU_MKL = chol_cpu_gpu_mkl/chol_cpu_gpu_mkl.cpp test/chol_cpu_gpu_mkl/one_gpu_factor.cpp

CHOL_OPENMP_SRC = chol_openmp/*.cpp

CHOL_MKL_SINGLE = chol_mkl_single/chol_mkl_single2.cpp

MKL_INCLUDE = $${MKLROOT}/include

CUDA_CHOL = cuda_chol
CHOL_CUDA_MGPU_NAME = chol_cuda_mgpu
TEST_CHOL_GPU_FACTOR_NAME = test_chol_gpu_factor
TEST_CHOL_GPU_FACTOR_NAME_DEBUG = test_chol_gpu_factor_debug
TEST_CHOL_SYS_SOLVE_NAME = test_chol_sys_solve
TEST_CHOL_SYS_SOLVE_NAME_DEBUG = test_chol_sys_solve_debug

TEST_CHOL_ONE_GPU_MKL_NAME = test_chol_one_gpu_mkl
TEST_CHOL_ONE_GPU_MKL_NAME_DEBUG = test_chol_one_gpu_mkl_debug
CHOL_OPENMP = chol_openmp
CHOL_MKL_SINGLE_NAME2 = chol_mkl_single2
CHOL_MKL_SINGLE_PARALLEL_NAME = chol_mkl_singlle_parallel

TEST_GAUS_GPU_FACTOR_NAME = test_gaus_gpu_factor
TEST_GAUS_GPU_FACTOR_NAME_DEBUG = test_gaus_gpu_factor_debug

TEST_GAUS_SYS_SOLVE_NAME = test_gaus_sys_solve
TEST_GAUS_SYS_SOLVE_NAME_DEBUG = test_gaus_sys_solve_debug

LIB_MKL = $${MKLROOT}/lib/intel64/
LIB_MKL_COMPILER = /opt/intel/composer_xe_2013.0.079/compiler/lib/intel64/
MKL_SEQ_LIBS = -lmkl_core -lmkl_sequential -lmkl_intel_lp64  -lm
MKL_PARALLEL_LIBS = -lmkl_core -lmkl_intel_thread -lmkl_intel_lp64 -lpthread -liomp5 -lm

.PHONY = cuda_chol cublas_matrix_copy_test

print:
	@echo $$PATH
	@echo ${MKL_INCLUDE}

#target for compiling simple cuda cholesky
cuda_chol:
	mkdir -p ${BIN_DIR}
	${COMPILER} --name ${BIN_DIR}/${CUDA_CHOL} --with-sdk --with-cublas -I${MKL_INCLUDE} -I${INCLUDE} -I${COMMON_INCLUDE} -L${LIB_MKL} ${MKL_SEQ_LIBS} ${COMMON_SRC} ${CHOL_CUDA_SRC}	

chol_cuda_mgpu_t:
	${COMPILER} --name ${BIN_DIR}/${CHOL_CUDA_MGPU_NAME} --with-sdk --with-cublas -I${MKL_INCLUDE} -I${INCLUDE} -I${COMMON_INCLUDE} -L${LIB_MKL} ${MKL_SEQ_LIBS}   ${COMMON_SRC} ${CHOL_CUDA_MGPU_SRC}	

debug_chol_cuda_mgpu_t:
	${COMPILER} --name ${BIN_DIR}/${CHOL_CUDA_MGPU_NAME} --with-sdk --with-cublas -I${MKL_INCLUDE} -I${INCLUDE} -I${COMMON_INCLUDE} -L${LIB_MKL} ${MKL_SEQ_LIBS}  -G -g ${COMMON_SRC} ${CHOL_CUDA_MGPU_SRC}		
	
test_chol_gpu_factor:
	${COMPILER} --name ${BIN_DIR}/${TEST_CHOL_GPU_FACTOR_NAME} --with-sdk --with-cublas -I${MKL_INCLUDE} -I${INCLUDE} -I${COMMON_INCLUDE} -L${LIB_MKL} ${MKL_SEQ_LIBS} ${COMMON_SRC} ${TEST_CHOL_GPU_FACTOR_SRC}		
	
test_chol_gpu_factor_debug:
	${COMPILER} --name ${BIN_DIR}/${TEST_CHOL_GPU_FACTOR_NAME_DEBUG} --with-sdk --with-cublas -I${MKL_INCLUDE} -I${INCLUDE} -I${COMMON_INCLUDE} -L${LIB_MKL} ${MKL_SEQ_LIBS} -g  ${COMMON_SRC} ${TEST_CHOL_GPU_FACTOR_SRC}			
	
test_chol_sys_solve:
	${COMPILER} --name ${BIN_DIR}/${TEST_CHOL_SYS_SOLVE_NAME} --with-sdk --with-cublas -I${MKL_INCLUDE} -I${INCLUDE} -I${COMMON_INCLUDE} -L${LIB_MKL} ${MKL_SEQ_LIBS} ${COMMON_SRC} ${TEST_CHOL_SYS_SOLVE_SRC}		
	
test_chol_sys_solve_debug:
	${COMPILER} --name ${BIN_DIR}/${TEST_CHOL_SYS_SOLVE_NAME_DEBUG} --with-sdk --with-cublas -I${MKL_INCLUDE} -I${INCLUDE} -I${COMMON_INCLUDE} -L${LIB_MKL} ${MKL_SEQ_LIBS} -g  ${COMMON_SRC} ${TEST_CHOL_SYS_SOLVE_SRC}				

test_chol_one_gpu_mkl:
	${COMPILER} --name ${BIN_DIR}/${TEST_CHOL_ONE_GPU_MKL_NAME} --with-sdk --with-cublas -I${MKL_INCLUDE} -I${INCLUDE} -I${COMMON_INCLUDE} -L${LIB_MKL} ${MKL_SEQ_LIBS} ${COMMON_SRC} ${TEST_CHOL_ONE_GPU_MKL}		
	
test_chol_one_gpu_mkl_debug:
	${COMPILER} --name ${BIN_DIR}/${TEST_CHOL_ONE_GPU_MKL_NAME_DEBUG} --with-sdk --with-cublas -I${MKL_INCLUDE} -I${INCLUDE} -I${COMMON_INCLUDE} -L${LIB_MKL} ${MKL_SEQ_LIBS} -g  ${COMMON_SRC} ${TEST_CHOL_ONE_GPU_MKL}					

chol_mkl_single2:
	${COMPILER} --name ${BIN_DIR}/${CHOL_MKL_SINGLE_NAME2}  -I${MKL_INCLUDE} -L${LIB_MKL} ${MKL_SEQ_LIBS}  ${CHOL_MKL_SINGLE}	

chol_mkl_singlle_parallel:
	${COMPILER} --name ${BIN_DIR}/${CHOL_MKL_SINGLE_PARALLEL_NAME}  -I${MKL_INCLUDE} -L${LIB_MKL}  -L${LIB_MKL_COMPILER} ${MKL_PARALLEL_LIBS}	 ${CHOL_MKL_SINGLE}

test_gaus_gpu_factor:
	${COMPILER} --name ${BIN_DIR}/${TEST_GAUS_GPU_FACTOR_NAME} --with-sdk --with-cublas -I${MKL_INCLUDE} -I${INCLUDE} -I${COMMON_INCLUDE} -L${LIB_MKL} ${MKL_SEQ_LIBS} ${COMMON_SRC} ${TEST_GAUS_GPU_FACTOR_SRC}		
	
test_gaus_gpu_factor_debug:
	${COMPILER} --name ${BIN_DIR}/${TEST_GAUS_GPU_FACTOR_NAME_DEBUG} --with-sdk --with-cublas -I${MKL_INCLUDE} -I${INCLUDE} -I${COMMON_INCLUDE} -L${LIB_MKL} ${MKL_SEQ_LIBS} -g  ${COMMON_SRC} ${TEST_GAUS_GPU_FACTOR_SRC}				

test_gaus_sys_solve:
	${COMPILER} --name ${BIN_DIR}/${TEST_GAUS_SYS_SOLVE_NAME} --with-sdk --with-cublas -I${INCLUDE} -I${COMMON_INCLUDE} ${COMMON_SRC} ${TEST_GAUS_SYS_SOLVE_SRC}		
	
test_gaus_sys_solve_debug:
	${COMPILER} --name ${BIN_DIR}/${TEST_GAUS_SYS_SOLVE_NAME_DEBUG} --with-sdk --with-cublas -I${INCLUDE} -I${COMMON_INCLUDE}  -g  ${COMMON_SRC} ${TEST_GAUS_SYS_SOLVE_SRC}					
	
	
	